﻿using Entity.Finance.DTO.IncomeAccount;
using Entity.Finance.DTO.IncomeManage;
using Entity.Finance.View.IncomeManage;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Service;
using Service.System;

namespace AnQinManagermentBackendAPI.Controller.Finance
{
    /// <summary>
    /// 应收款管理
    /// </summary>
    [Route("api/[controller]")]
    [ApiController]
    [Authorize]
    [AllowAnonymous]
    public class IncomeManagesController : ControllerBase
    {
        /**
         * 业务接口
         */
        private readonly IncomeManageService _service;

        /**
         * 构造函数注入
         */
        public IncomeManagesController(IncomeManageService service)
        {
            _service = service;
        }

        /// <summary>
        /// 获取列表
        /// </summary>
        [HttpGet]
        [ProducesResponseType(typeof(IncomeManageView), 200)]
        public async Task<IActionResult> GetIncomeManageList([FromQuery] IncomeManageSearchDTO model)
        {
            var response = await _service.GetIncomeManageList(model);
            return StatusCode(response.Status, response);
        }

        /// <summary>
        /// 收款
        /// </summary>
        [HttpPost("Income")]
        public async Task<IActionResult> Income([FromBody] IncomeManageIncomeDto model)
        {
            var response = await _service.Income(model);
            return StatusCode(response.Status, response);
        }
        
        /// <summary>
        /// 退款
        /// </summary>
        [HttpPost("Return")]
        public async Task<IActionResult> Return([FromBody] IncomeManageIncomeDto model)
        {
            var response = await _service.Return(model);
            return StatusCode(response.Status, response);
        }

        /// <summary>
        /// 删除
        /// </summary>
        [HttpDelete]
        public async Task<IActionResult> DeleteIncomeManage([FromQuery] string Id)
        {
            var response = await _service.DeleteIncomeManage(Id);
            return StatusCode(response.Status, response);
        }

    }
}
